# CalBMIv3.py
def get_float_input(prompt):
    while True:
        try:
            return float(input(prompt))
        except ValueError:
            print("输入错误：请输入有效的数值。")

def calculate_bmi():
    height = get_float_input("输入身高（米）：")
    weight = get_float_input("输入体重（公斤）：")
    bmi = weight / (height ** 2)
    print("BMI 数值为：{:.2f}".format(bmi))

    who, nat = "", ""
    if bmi < 18.5:
        who, nat = "偏瘦", "偏瘦"
    elif 18.5 <= bmi < 24:
        who, nat = "正常", "正常"
    elif 24 <= bmi < 25:
        who, nat = "正常", "偏胖"
    elif 25 <= bmi < 28:
        who, nat = "偏胖", "偏胖"
    elif 28 <= bmi < 30:
        who, nat = "偏胖", "肥胖"
    else:
        who, nat = "肥胖", "肥胖"
    print("BMI 指标为:国际'{0}', 国内'{1}'".format(who, nat))

    again = input("是否要继续计算另一位的BMI？(yes/no)：")
    if again.lower() == 'yes':
        calculate_bmi()

calculate_bmi()